<?php

namespace app\company\controller\user_profile\userArchive\evaluationArchive;

use app\company\service\user_profile\userArchive\evaluationArchive\EvaluationArchiveService;
use app\BaseController;
use app\common\Message;

class EvaluationArchive extends BaseController
{
    use Message;

    /**
     * 测评档案概况
     * @return bool|string
     */
    public function getOverview(): bool|string
    {
        try {
            $param = $this->request->param();
            $this->validate($param,[
                'unit_id|单位ID' => 'require|integer'
            ]);
            $EvaluationArchive = new EvaluationArchiveService($this->app);
            if(!$EvaluationArchive->getOverview($param)) throw new \Exception($EvaluationArchive->getMessage());
            return success($EvaluationArchive->getResult(),$EvaluationArchive->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }

    /**
     * 自我测评记录
     * @return bool|string
     */
    public function getSelfRecode(): bool|string
    {
        try {
            $param = $this->request->param();
            $this->validate($param,[
                'unit_id|单位ID' => 'require|integer'
            ]);
            $EvaluationArchive = new EvaluationArchiveService($this->app);
            if(!$EvaluationArchive->getSelfRecode($param)) throw new \Exception($EvaluationArchive->getMessage());
            return success($EvaluationArchive->getResult(),$EvaluationArchive->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }

    /**
     * 任务测评记录
     * @return bool|string
     */
    public function getTaskRecode(): bool|string
    {
        try {
            $param = $this->request->param();
            $this->validate($param,[
                'unit_id|单位ID' => 'require|integer'
            ]);
            $EvaluationArchive = new EvaluationArchiveService($this->app);
            if(!$EvaluationArchive->getTaskRecode($param)) throw new \Exception($EvaluationArchive->getMessage());
            return success($EvaluationArchive->getResult(),$EvaluationArchive->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }
    /**
     * 他人测评记录
     * @return bool|string
     */
    public function getProxyRecode(): bool|string
    {
        try {
            $param = $this->request->param();
            $this->validate($param,[
                'unit_id|单位ID' => 'require|integer'
            ]);
            $EvaluationArchive = new EvaluationArchiveService($this->app);
            if(!$EvaluationArchive->getProxyRecode($param)) throw new \Exception($EvaluationArchive->getMessage());
            return success($EvaluationArchive->getResult(),$EvaluationArchive->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }

}